﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TextEditorDP
{
    public class ClearCommand: Command
    {
        string history;
        CRichTextBox editor;
        public ClearCommand(ref CRichTextBox editor)
        {
            this.editor = editor;
        }

        #region Command Members

        public bool Execute()
        {
            history = editor.Rtf;
            editor.SelectedText = String.Empty;
            return true;
        }

        public void UnExecute()
        {
            editor.Rtf = history;
        }

        public bool CanUndo()
        {
            return true;
        }

        #endregion
    }
}
